package Servers

import (
	"DBModel"
	ai "GameLogic/AIRobot"
	"PBMessage"
	"SGNet"
	. "Servers/BaseServer"
	"container/list"
	"utils/uuid"
)

const (
	EnumPlayerState_Hall      = 0
	EnumPlayerState_MatchGame = 1
	EnumPlayerState_ReadyRoom = 2
	EnumPlayerState_Lost      = 3
)

type HallPlayer struct {
	UserId         int64
	Account        *DBModel.AccountModel
	Sess           *SGNet.Session
	MatchRef       *list.Element
	PlayerState    int
	hallServer     *HallServer
	readyRoom      *ReadyRoom
	IsRobotValue   bool
	AIUnit         *ai.AIUnit
	ReadRoomPlayer *PBMessage.ReadRoomPlayer
}

func NewHallPlayer(account *DBModel.AccountModel, sess *SGNet.Session, aiUnit *ai.AIUnit) *HallPlayer {
	retHallPlayer := &HallPlayer{
		Account:     account,
		Sess:        sess,
		PlayerState: EnumPlayerState_Hall,
		UserId:      uuid.Int64UUID(),
		AIUnit:      aiUnit,
	}
	if aiUnit != nil {
		retHallPlayer.IsRobotValue = true
		retHallPlayer.UserId = uuid.Int64UUID()
		retHallPlayer.Account = &DBModel.AccountModel{}
		retHallPlayer.Account.Account = "Iamrobot"
		retHallPlayer.Account.NickName = "i am a robot"
		aiUnit.PlayerUUID = retHallPlayer.UserId
	}
	return retHallPlayer
}

func (this *HallPlayer) IsRobot() bool {
	return this.IsRobotValue
}

func (hallPlayer *HallPlayer) GetUserId() int64 {
	return hallPlayer.UserId
}
func (hallPlayer *HallPlayer) GetAccountModel() *DBModel.AccountModel {
	return hallPlayer.Account
}

func (hallPlayer *HallPlayer) GetSeesion() *SGNet.Session {
	return hallPlayer.Sess
}

func (hallPlayer *HallPlayer) GetServer() IServer {
	return hallPlayer.hallServer
}

func (hallPlayer *HallPlayer) GetReadyPlayerInfo() *PBMessage.ReadRoomPlayer {
	return hallPlayer.ReadRoomPlayer
}

func (this *HallPlayer) GetGenericPlayer() *GenericPlayer {
	return nil
}
